<?php
namespace app\home\controller;

use think\Controller;
use think\Db;
use think\Request;
use think\Session;

class Index extends Controller{

    /*
     *  首页显示
     * */
    public function index()
    {
        $res = Db::table('courses')
            ->where('courses_del',0)
            ->limit(4)
            ->order('rand()')
            ->select();

        $row = Db::table('courses')
            ->where('courses_del',0)
            ->limit(4)
            ->order('rand()')
            ->select();


        $rex=1;
        $rex2=2;
        $rex3=3;
        $rex4=4;
        $this->assign('rex',$rex);
        $this->assign('rex2',$rex2);
        $this->assign('rex3',$rex3);
        $this->assign('rex4',$rex4);

        $userSession = Session::get("USERS");
        $this->view->assign("user_id",$userSession['user_id']);
        $this->view->assign("res",$res);
        $this->view->assign("row",$row);

        //最新动态
        $title = Db::table("article")->where("article_del = 0")->order('article_time desc')->limit(4)->select();
        $this->assign("title",$title);

        return $this->view->fetch();
    }
    /*
     * 登录页面
     * */
    public function login(){

         return $this->fetch();

    }

    /*
     *
     * 注册页面
     * */
    public function register(){

        return $this->fetch();
    }
    /*
      *
      * 联系我们
      * */
    public function contact(){

        $userSession = Session::get("USERS");
        $this->view->assign("user_id",$userSession['user_id']);
        $res = Db::table('contact')->find();
        $this->assign('address',$res['address']);
        $this->assign('qq',$res['qq']);
        $this->assign('email',$res['email']);
        $this->assign('blog',$res['blog']);
        $this->assign('phone',$res['phone']);
        $this->assign('title',$res['title']);
        return $this->fetch();
    }
}

